<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="js/mui.min.js"></script>
			<link href="css/mui.min.css" rel="stylesheet" />
		
			<link rel="stylesheet" type="text/css" href="../../../../../cdn.bootcss.com/layer/3.0.1/mobile/need/layer.css" />
			<link rel="stylesheet" type="text/css" href="css/style.css" />
			<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
			<script type="text/javascript" src="js/phone.js"></script>
			<script type="text/javascript" src="../../../../../cdn.bootcss.com/layer/3.0.1/mobile/layer.min.js"></script>
			<script type="text/javascript" src="js/login.js"></script>
			<script type="text/javascript" charset="utf-8">
				mui.init();
			</script>
		</head>
		<body>
			<div class="whole">
				<div class="title">注册</div>
				<div class="login-form">
					<form method="get" id="form">
						<div class="user-name common-div">
							<span class="eamil-icon common-icon">
								<img src="image/eamil.png" />
							</span>
							<input id="username" name="user.username" value="" placeholder="用户名" />
						</div>
						<div class="user-pasw common-div">
							<span class="pasw-icon common-icon">
								<img src="image/password.png" />
							</span>
							<input id="password" type="password" name="user.password" value="" placeholder="密码" />
						</div>
						<div class="user-name common-div">
							<span class="eamil-icon common-icon">
								<img src="image/eamil.png" />
							</span>
							<input id="user_name" name="user.user_name" value="" placeholder="昵称" />
						</div>
						<div class="user-name common-div">
							<span class="eamil-icon common-icon">
								<img src="image/eamil.png" />
							</span>
							<input id="sex" name="user.sex" value="" placeholder="性别" />
						</div>
						<div class="user-name common-div">
							<span class="eamil-icon common-icon">
								<img src="image/eamil.png" />
							</span>
							<input id="age" name="user.age" value="" placeholder="年龄" />
						</div>
						<button type="submit" class="login-btn common-div" id="register">注册</button>
					</form>
				</div>
				<div class="forgets">
					<a href="index.html">已有账号？选择登录</a>
				</div>
			</div>
			<script>
				var btn = document.getElementById("register");
				//监听点击事件
				btn.addEventListener("tap", function() {
					alert(typeof(mui("#username")[0].value))
					console.log("aaaaa");
					$.ajax({
						url: window.localStorage.getItem("url")+"login/register",
						data:$("#form").serialize(), /* {
							username: mui("#username")[0].value,
							password: mui("#password")[0].value,
							user_name: mui("#user_name")[0].value,
							sex: mui("#sex")[0].value,
							age: mui("#age")[0].value
						}, */
						type: 'GET',
						dataType: 'JSONP',
						contentType: "application/x-www-form-urlencoded; charset=UTF-8",
						async: false,
						cache: false,
						processData: true,
						success: function(data) {
							if(data.success == "success"){
								mui.alert('注册成功！','消息提示','确认',function (e) {
								   mui.openWindow({
								   	url: './index.html',
								   });
								   setTimeout(function() {
								   	plus.webview.currentWebview().close();
								   }, 1000);
								},'div')
							}else{
								mui.alert('注册失败╮(・o・)╭','消息提示','确认',function (e) {
								   e.index
								},'div')
							}
						},
						error: function(XMLHttpRequest, textStatus, errorThrown) {
							//异常处理；
							alert(textStatus);
						}
					});
				});
			</script>
		</body>

</html>
